package com.gemini.main.model.dto;

import com.gemini.main.common.convert.DTOConvert;
import com.gemini.main.model.SysUser;
import lombok.Builder;
import lombok.Data;
import org.springframework.beans.BeanUtils;

/**
 * Wisdytech.cn
 * com.gemini.main.model.dto.UserDTO
 *
 * @author hailin.zhl
 * @date 2018/12/07
 */
@Data
@Builder
public class UserDTO {

    private Long id;

    private String username;

    private String password;

    public SysUser convertToUser() {
        UserDTOConvert convert = new UserDTOConvert();
        return convert.convert(this);
    }

    private static class UserDTOConvert implements DTOConvert<UserDTO, SysUser> {

        @Override
        public SysUser convert(UserDTO userDTO) {
            SysUser user = new SysUser();
            BeanUtils.copyProperties(userDTO, user);
            return user;
        }
    }
}
